<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" type="text/css" href="<%=path %>/static/css/css.css?1" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/jquery-ui/jquery-ui.min.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/static/bootstrap/bootstrap.css" />
<script type="text/javascript" src="<%=path %>/static/js/json2.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/jquery.js"></script>
<script type="text/javascript" src="<%=path %>/static/jquery-ui/jquery-ui.min.js"></script>
<script type="text/javascript" src="<%=path %>/static/layer/layer.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/gridview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/formview.js?v=1"></script>
<script type="text/javascript" src="<%=path %>/static/js/tool.js"></script>
<script type="text/javascript" src="<%=path %>/static/js/validate.js"></script>
<script type="text/javascript" src="<%=path %>/static/bootstrap/bootstrap.js"></script>

<SCRIPT type="text/javascript">
    <!--
	var gridSetting = {
			id:'QhUserGrid',
			po:"UserView1",
			title:'用户列表',
			height:'auto',
			service:"uiServices!listSimple",
			tbId:"UserTb",
			hideCheckbox:true,
			pageInfo: {
				records: 12,//auto表示根据容器高度自动判断
				orderby : "leav, desc"
			},
			oper:{
                isDisplay:true,
            	operName:"",
            	url:"",
            	cssClass:"classOperation",
            	width:80
            },
			fields:[
			   {	name:'id',
					hide:true
			   },
               {
                   name: 'mobile',
                   descs:"手机号",
                   align:'center',
                   thstyle:"width:106px",
               },
               {
                   name: 'srcPla',
                   align:'center',
                   descs:"来源渠道"
               },
               {
                   name: 'leaveName',
                   align:'center',
                   descs:"等级"
               },
               {
                   name: 'apprentCnt',
                   align:'center',
                   descs:"徒弟"
               },
               {
                   name: 'totalFund',
                   align:'center',
                   descs:"总资金"
               },
               {
                   name: 'availFund',
                   align:'center',
                   descs:"钱包余额"
               },
               {
                   name: 'taskProfit',
                   align:'center',
                   descs:"任务佣金"
               },
               {
                   name: 'taskCnt',
                   align:'center',
                   descs:"分享任务数"
               },
               {
                   name: 'contiCnt',
                   align:'center',
                   descs:"继续分享数"
               }
               ,{
                   name: 'createDateTime',
                   descs:"注册时间",
                   align:'center',
                   thstyle:"width:140px",
                   type:'datetime'
               }
			]
		};
	var grid;
    $(document).ready(function(){
    	grid = new GridView("list",gridSetting,"list");
		grid.init();
		var data = [];
		data.push({r:"=",name:'isLogin',value:1});

		grid.load({data:data});

		ajustHeight();

    });

    //-->
</SCRIPT>
</head>

<body>
<ul class=tab_nav>
  <li>
    <a class="current" href="javascript:void(0)">用户管理</a>
  </li>
</ul>
<div class="contrainer">
<div class="rcon2" >

<table class="search_tb">
   <tr>
      <td><input type="text" style="width:80px" name="id" placeholder="ID" /></td>
      <td>
         <select name="state" style="width:100px;">
            <option value="">状态</option>
            <option value="1">正常</option>
            <option value="-1">停用</option>
         </select>
      </td>
      <td>
         <select name="leav" style="width:100px;">
            <option value="">等级</option>
            <option value="1">一尾狐</option>
            <option value="2">二尾狐</option>
            <option value="3">三尾狐</option>
            <option value="4">四尾狐</option>
            <option value="5">五尾狐</option>
            <option value="6">六尾狐</option>
            <option value="7">七尾狐</option>
            <option value="8">八尾狐</option>
            <option value="9">九尾狐</option>
         </select>
      </td>
      <td>
         <select name="srcPla" style="width:100px;">
            <option value="">渠道</option>
            <option value="qf_8">应用宝</option>
            <option value="qf_13">推啊</option>
            <option value="qf_14">任务分享</option>
         </select>
      </td>
      <td><input type="text" style="width:80px" name="name" placeholder="姓名" /></td>
      <td><input type="text" style="width:80px" name="mobile" placeholder="手机号" /></td>
      <td>
         <div style="float:left">
             <input type="text" style="width:80px" onclick="WdatePicker()" name="createDateTime" placeholder="开始时间" />-<input type="text" style="width:80px" onclick="WdatePicker()" name="createDateTime" placeholder="结束时间" />
         </div>
         <input type="button" class="searchbtn" value="" id="queryBtn">
         <div style="margin-left:20px;margin-top:5px;font-size:14px;float:left;">
            总人数：<span id="TotalNum" style="margin-right:8px;"></span>
            徒弟总人数：<span id="ApprentNum" style="margin-right:8px;"></span>
            团队总人数：<span id="TeamNum" style="margin-right:8px;"></span>
            在线人数：<span id="OnlineNum"></span>
         </div>
      </td>

   </tr>
</table>
</div>
<div id="formview" class="rbox1"></div>
<div id="list" class="rbox2"></div>
</div>

<script type="text/javascript" src="<%=path %>/static/js/underscore.js"></script>
<script type='text/javascript' src='<%=path %>/static/My97DatePicker/WdatePicker.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/util.js'></script>
<script type='text/javascript' src='<%=path %>/dwr/interface/BaseDwr.js'></script>
<script>
    $(function(){

    });

    $("#queryBtn").click(function(){

       var id = $(".search_tb").find(":input[name=id]").val();
       var state = $(".search_tb").find(":input[name=state]").val();
       var leav = $(".search_tb").find(":input[name=leav]").val();
       var srcPla = $(".search_tb").find(":input[name=srcPla]").val();
       var name = $(".search_tb").find(":input[name=name]").val();
       var mobile = $(".search_tb").find(":input[name=mobile]").val();
       var createDateTime1 = $(".search_tb").find(":input[name=createDateTime]:eq(0)").val();
       var createDateTime2 = $(".search_tb").find(":input[name=createDateTime]:eq(1)").val();

       var data = [];
       data.push({r:"=",name:'isLogin',value:1});
       if(state!==""){
          data.push({r:"=",name:'state',value:state});
       }
       if(leav!==""){
          data.push({r:"=",name:'leav',value:leav});
       }
       if(srcPla!==""){
          data.push({r:"=",name:'srcPla',value:srcPla});
       }
       if(id!==""){
          data.push({r:"=",name:'id',value:id});
       }
       if(name!==""){
          data.push({r:"like",name:'name',value:"%"+name+"%"});
       }
       if(mobile!==""){
          data.push({r:"like",name:'mobile',value:"%"+mobile+"%"});
       }
       if(createDateTime1!==""){
          data.push({r:">=",name:'createDateTime',value:createDateTime1});
       }
       if(createDateTime2!==""){
          data.push({r:"<=",name:'createDateTime',value:createDateTime2});
       }

       grid.load({data:data});

    });

    function afterLoad_UserTb(){

       $(".rcon2 .mtable tbody tr").each(function(){
          var id=$(this).attr("recordid");
          var state=$(this).find("td[name=staval]").text();

          var html="";
          html += '<div class="btn-group" onclick="openmenu(this)">';
          html += '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button>';

          html += '<ul class="dropdown-menu" role="menu">';
          if(state=="正常"){
             html+="<li><a href='javascript:setState("+id+",-1)'>停用</a></li>";
          }
          else{
             html+="<li><a href='javascript:setState("+id+",1)'>启用</a></li>";
          }
          var mobile=$(this).find("td[name=mobile]").text();
          html+="<li><a  href='<%=path %>/public/common/r2.htmls?page=fund/user_cash_list&mobile="+mobile+"'>提现记录</a></li>";
          html+="<li><a  href='<%=path %>/public/common/r2.htmls?page=fund/user_recharge_list&mobile="+mobile+"'>充值记录</a></li>";
          html+="<li><a  href='<%=path %>/public/common/r2.htmls?page=fund/user_profit_list&mobile="+mobile+"'>收益记录</a></li>";
          html+="<li><a  href='<%=path %>/public/common/r2.htmls?page=notice/notice_list&uid="+id+"'>系统公告</a></li>";
          html+='</ul>';
          html+='</div>';
          $(this).find(".classOperation").html(html);

          var umobile=$(this).find("td[name=mobile]");
          var uhtml="<a href='<%=path %>/public/common/r2.htmls?page=user/user_view&id="+id+"'>"+umobile.text()+"</a>";
          umobile.html(uhtml);

          $srcPla=$(this).find("td[name=srcPla]");
          if($srcPla.text()=="qf_13"){
             $srcPla.text("推啊");
          }
          else if($srcPla.text()=="qf_8"){
             $srcPla.text("应用宝");
          }
          else if($srcPla.text()=="qf_14"){
             $srcPla.text("任务分享");
          }
       });

       $("#TotalNum").text($(".tablef b").text());

       var srcPla=$(".search_tb").find(":input[name=srcPla]").val();
       var createDateTime1 = $(".search_tb").find(":input[name=createDateTime]:eq(0)").val();
       var createDateTime2 = $(".search_tb").find(":input[name=createDateTime]:eq(1)").val();

       $.getJSON(g_path+"/public/common/getApprentCnt.htmls",{srcPla:srcPla,createDateTime1:createDateTime1,createDateTime2:createDateTime2},function(data){
          $("#ApprentNum").text(data.apprentCnt);
          if(srcPla!=""){
             $("#TeamNum").text(data.teamCnt);
          }
          else{
             $("#TeamNum").text("0");
          }
          $("#OnlineNum").text(data.onlineCnt);
       });

    }
    function setState(id,state){
       $.getJSON(g_path+"/public/common/userStateEdit.htmls",{id:id,state:state},function(data){
          layer.alert("操作成功！");
          grid.reload();
       });
    }
    function openmenu(obj){
       if($(obj).hasClass("open")){
          $(obj).removeClass("open");
       }else{
          $(obj).addClass("open");
       }
    }
</script>
</body>
</html>